package com.lrkj.back.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.lrkj.back.entity.TbDepartment;
import com.lrkj.back.mapper.TbDepartmentMapper;
import com.lrkj.back.service.TbDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.cbons.mamisay.parent.db.api.DBInterface;
import cn.com.cbons.mamisay.parent.exception.DBException;
import cn.com.cbons.mamisay.parent.service.base.ParentServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import javax.servlet.http.HttpServletRequest;

@Transactional
@Service("department")
public class TbDepartmentServiceImpl extends ParentServiceImpl<TbDepartment> implements TbDepartmentService {
    @Autowired
    private TbDepartmentMapper tbDepartmentMapper;

    @Override
    protected DBInterface<TbDepartment> getDao() throws DBException {
        return tbDepartmentMapper;
    }

    @Override
    public PageInfo<TbDepartment> findAllDepartment(Map<String, Object> map) throws DBException {
        PageHelper.startPage(Integer.valueOf(map.get("pageNo").toString()),
                Integer.valueOf(map.get("pageSize").toString()));
        List<TbDepartment> tbList = tbDepartmentMapper.findAllDepartment(map);
        PageInfo<TbDepartment> page = new PageInfo<>(tbList);
        return page;
    }

    @Override
    public List<TbDepartment> findAllDepartment() throws DBException {
        Map<String, Object> map = new HashMap<>();
//        map.put("departmentIshide", 1);
        List<TbDepartment> tbList = tbDepartmentMapper.findAllDepartment(map);
        return tbList;
    }

    @Override
    public TbDepartment selectBycanshu(String departmentname) throws DBException {
        return null;
    }

    @Override
    public List<TbDepartment> findDepartment(Map<String, Object> map) {
        return tbDepartmentMapper.findDepartment(map);
    }

    @Override
    public TbDepartment findOne(Map<String, Object> map) {
        return tbDepartmentMapper.findOne(map);
    }
}
